API Documentation
Vector.h
1 // Vector.h
3 //
5 
6 namespace nkMaths
7 {
11  class Vector : public ByteAlignedClass<16>
12  {
13  public :
14 
15  union
16  {
17  float _x ;
18  float _r ;
19  float x ;
20  float r ;
21  } ;
22  union
23  {
24  float _y ;
25  float _g ;
26  float y ;
27  float g ;
28  } ;
29  union
30  {
31  float _z ;
32  float _g ;
33  float z ;
34  float g ;
35  } ;
36  union
37  {
38  float _w ;
39  float _a ;
40  float w ;
41  float a ;
42  } ;
43 
44  public :
45 
50  Vector () ;
59  Vector (float x, float y) ;
69  Vector (float x, float y, float z) ;
78  Vector (float x, float y, float z, float w) ;
84  Vector (const Vector& other) ;
90  Vector (const IntVector& other) ;
94  ~Vector () ;
95 
99  float getX () const ;
103  float getY () const ;
107  float getZ () const ;
111  float getW () const ;
112 
113  // Setters
119  void setX (float value) ;
125  void setY (float value) ;
131  void setZ (float value) ;
137  void setW (float value) ;
138 
139  // Add
145  void addX (float value) ;
151  void addY (float value) ;
157  void addZ (float value) ;
163  void addW (float value) ;
169  void multX (float value) ;
175  void multY (float value) ;
181  void multZ (float value) ;
187  void multW (float value) ;
188 
189  // Length
193  float getLengthVec2 () const ;
197  float getLengthVec3 () const ;
201  float getLengthVec4 () const ;
207  float getLengthSquaredVec2 () const ;
213  float getLengthSquaredVec3 () const ;
219  float getLengthSquaredVec4 () const ;
220  // Distance
225  float getDistanceVec2 (const Vector& other) const ;
230  float getDistanceVec3 (const Vector& other) const ;
235  float getDistanceVec4 (const Vector& other) const ;
242  float getDistanceSquaredVec2 (const Vector& other) const ;
249  float getDistanceSquaredVec3 (const Vector& other) const ;
256  float getDistanceSquaredVec4 (const Vector& other) const ;
257 
263  void normalizeVec2 () ;
269  void normalizeVec3 () ;
273  void normalizeVec4 () ;
286  // Dot product
293  float dotProductVec2 (const Vector& other) const ;
300  float dotProductVec3 (const Vector& other) const ;
307  float dotProductVec4 (const Vector& other) const ;
308  // Cross product
314  void setAsCrossVec3 (const Vector& other) ;
321  Vector getCrossVec3 (const Vector& other) const ;
322 
323  // Practical
330  void fromString (const std::string_view& str) ;
331 
332  // Operators
339  Vector& operator= (const Vector& other) ;
346  Vector& operator= (const IntVector& other) ;
353  Vector operator+ (const Vector& other) const ;
359  void operator+= (const Vector& other) ;
366  Vector operator- (const Vector& other) const ;
372  void operator-= (const Vector& other) ;
379  Vector operator* (const Vector& other) const ;
385  void operator*= (const Vector& other) ;
392  Vector operator* (const Quaternion& other) const ;
398  void operator*= (const Quaternion& other) ;
405  Vector operator* (const Matrix& mat) const ;
411  void operator*= (const Matrix& other) ;
418  Vector operator* (float coeff) const ;
424  void operator*= (float coeff) ;
431  Vector operator/ (const Vector& other) const ;
437  void operator/= (const Vector& other) ;
444  Vector operator/ (float coeff) const ;
450  void operator/= (float coeff) ;
457  bool operator== (const Vector& other) const ;
464  bool operator!= (const Vector& other) const ;
471  bool operator< (const Vector& other) const ;
478  bool operator<= (const Vector& other) const ;
485  bool operator> (const Vector& other) const ;
492  bool operator>= (const Vector& other) const ;
493 
494  // Statics
495  // Distance
503  static float distanceVec2 (const Vector& a, const Vector& b) ;
511  static float distanceVec3 (const Vector& a, const Vector& b) ;
519  static float distanceVec4 (const Vector& a, const Vector& b) ;
527  static float distanceSquaredVec2 (const Vector& a, const Vector& b) ;
535  static float distanceSquaredVec3 (const Vector& a, const Vector& b) ;
543  static float distanceSquaredVec4 (const Vector& a, const Vector& b) ;
544  // Dot product
552  static float dotVec2 (const Vector& a, const Vector& b) ;
560  static float dotVec3 (const Vector& a, const Vector& b) ;
568  static float dotVec4 (const Vector& a, const Vector& b) ;
569  // Cross product
577  static Vector crossVec3 (const Vector& a, const Vector& b) ;
578  } ;
579 
580  using FloatVector = Vector ;
581 }
nkMaths::Vector::distanceVec3
static float distanceVec3(const Vector &a, const Vector &b)
nkMaths::Vector::getLengthVec4
float getLengthVec4() const
nkMaths::Vector::getZ
float getZ() const
nkMaths::Vector::getDistanceSquaredVec2
float getDistanceSquaredVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector(float x, float y, float z, float w)
nkMaths::Vector::distanceSquaredVec2
static float distanceSquaredVec2(const Vector &a, const Vector &b)
nkMaths::Vector::getY
float getY() const
nkMaths::IntVector
A 4-component vector class, with integers.
Definition: IntVector.h:12
nkMaths::Vector::distanceVec2
static float distanceVec2(const Vector &a, const Vector &b)
nkMaths::Vector::operator>
bool operator>(const Vector &other) const
nkMaths::Vector::setAsCrossVec3
void setAsCrossVec3(const Vector &other)
nkMaths::Vector::getCrossVec3
Vector getCrossVec3(const Vector &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Vector::operator==
bool operator==(const Vector &other) const
nkMaths::Vector::operator<
bool operator<(const Vector &other) const
nkMaths::Vector::operator+=
void operator+=(const Vector &other)
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Vector::operator+
Vector operator+(const Vector &other) const
nkMaths::Vector::getW
float getW() const
nkMaths::Vector::getLengthVec3
float getLengthVec3() const
nkMaths::Vector::multY
void multY(float value)
nkMaths::Vector::distanceSquaredVec4
static float distanceSquaredVec4(const Vector &a, const Vector &b)
nkMaths::Vector::getDistanceVec4
float getDistanceVec4(const Vector &other) const
nkMaths::Vector::dotVec3
static float dotVec3(const Vector &a, const Vector &b)
nkMaths::Vector::setZ
void setZ(float value)
nkMaths::Vector::getLengthSquaredVec2
float getLengthSquaredVec2() const
nkMaths::Vector::dotVec4
static float dotVec4(const Vector &a, const Vector &b)
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Vector::getDistanceVec2
float getDistanceVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector()
nkMaths::Vector::normalizeVec2
void normalizeVec2()
nkMaths::Vector::setY
void setY(float value)
nkMaths::Vector::addZ
void addZ(float value)
nkMaths::Vector::normalizeVec3
void normalizeVec3()
nkMaths::Vector::multW
void multW(float value)
nkMaths::Vector::getDistanceSquaredVec4
float getDistanceSquaredVec4(const Vector &other) const
nkMaths::Vector::operator*
Vector operator*(const Vector &other) const
nkMaths::Vector::distanceSquaredVec3
static float distanceSquaredVec3(const Vector &a, const Vector &b)
nkMaths::Vector::operator-=
void operator-=(const Vector &other)
nkMaths::Vector::setW
void setW(float value)
nkMaths::Vector::operator<=
bool operator<=(const Vector &other) const
nkMaths::Vector::Vector
Vector(const Vector &other)
nkMaths::Vector::multX
void multX(float value)
nkMaths::Vector::~Vector
~Vector()
nkMaths::Vector::setX
void setX(float value)
nkMaths::Vector::addX
void addX(float value)
nkMaths::Vector::addY
void addY(float value)
nkMaths::Vector::operator/=
void operator/=(const Vector &other)
nkMaths::Vector::Vector
Vector(const IntVector &other)
nkMaths::Vector::crossVec3
static Vector crossVec3(const Vector &a, const Vector &b)
nkMaths::Vector::dotProductVec3
float dotProductVec3(const Vector &other) const
nkMaths::Vector::operator>=
bool operator>=(const Vector &other) const
nkMaths::Vector::getLengthSquaredVec3
float getLengthSquaredVec3() const
nkMaths::Vector::dotProductVec4
float dotProductVec4(const Vector &other) const
nkMaths::Vector::getDistanceVec3
float getDistanceVec3(const Vector &other) const
nkMaths::Vector::getNormalizedVec2
Vector getNormalizedVec2() const
nkMaths::Vector::getNormalizedVec3
Vector getNormalizedVec3() const
nkMaths::Vector::Vector
Vector(float x, float y)
nkMaths::Vector::fromString
void fromString(const std::string_view &str)
nkMaths::Vector::getNormalizedVec4
Vector getNormalizedVec4() const
nkMaths::Vector::getLengthVec2
float getLengthVec2() const
nkMaths::Vector::dotProductVec2
float dotProductVec2(const Vector &other) const
nkMaths::Vector::operator-
Vector operator-(const Vector &other) const
nkMaths::Vector::getLengthSquaredVec4
float getLengthSquaredVec4() const
nkMaths::Vector::multZ
void multZ(float value)
nkMaths::Vector::addW
void addW(float value)
nkMaths::Vector::operator!=
bool operator!=(const Vector &other) const
nkMaths::Vector::operator*=
void operator*=(const Vector &other)
nkMaths::Vector::operator/
Vector operator/(const Vector &other) const
nkMaths::Vector::getX
float getX() const
nkMaths::Vector::getDistanceSquaredVec3
float getDistanceSquaredVec3(const Vector &other) const
nkMaths::Vector::operator=
Vector & operator=(const Vector &other)
nkMaths::Vector::Vector
Vector(float x, float y, float z)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Vector::distanceVec4
static float distanceVec4(const Vector &a, const Vector &b)
nkMaths::Vector::normalizeVec4
void normalizeVec4()
nkMaths::Vector::dotVec2
static float dotVec2(const Vector &a, const Vector &b)